/*
 * userapp_uartProtocol.h
 *
 *  Created on: 2025锟斤拷3锟斤拷7锟斤拷
 *      Author: dai
 */

#ifndef USERAPP_USERAPP_UARTPROTOCOL_H_
#define USERAPP_USERAPP_UARTPROTOCOL_H_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HEADER_SIZE 2 //帧头长度
#define COMMAND_SIZE 1 //命令长度
#define LENGTH_SIZE 1 //内容长度
#define MAX_CONTENT_SIZE 128  //内容长度

#define HEADER_CHAR0 'W' //帧头0
#define HEADER_CHAR1 'X' //帧头1

#define COMMAND_SETID 'I'  //设置ID
#define COMMAND_SENDDATA 'D'  //传输数据
#define COMMAND_SETMODE 'M'  //设置模式

typedef struct {
    unsigned char
 header[HEADER_SIZE];
    unsigned char
 command;
    unsigned char
 contentLength;
    unsigned char
 content[MAX_CONTENT_SIZE];
    unsigned char
 checksum;
} ProtocolFrame;

int UartProtocol_test(unsigned char *exampleData,int length);

#endif /* USERAPP_USERAPP_UARTPROTOCOL_H_ */
